﻿@model Helper.Core.Entity.Status


@{
    ViewBag.Title = "Criar";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<h2>Criar</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>


<script>
    Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.state.*',
'Ext.selection.CheckboxModel'
]);

    Ext.onReady(function () {

        Ext.define('Sector', {
            extend: 'Ext.data.Model',
            fields: [
	   { name: 'Id', type: 'int' },
	   { name: 'Name', type: 'string' }
	],
            idProperty: 'Id'
        });


        var myData = Ext.create('Ext.data.Store', {
            autoLoad: true,
            autoSync: true,
            model: 'Sector',
            storeId: 'Id',
            proxy: {
                type: 'rest',
                url: '../Sector/GetAll',
                reader: {
                    type: 'json',
                    root: 'sectors'
                },
                writer: {
                    type: 'json'
                }
            }
        });

        // create the data store
        /* var storeData = Ext.create('Ext.data.ArrayStore', {
        model: 'Sector',
        data: myData
        }); */

        var sm = Ext.create('Ext.selection.CheckboxModel');

        var grid = Ext.create('Ext.grid.Panel', {
            store: myData,
            selModel: sm,
            stateful: true,
            collapsible: true,
            multiSelect: true,
            stateId: 'stateGrid',
            columns: [
            {
                text: 'Nome',
                flex: 1,
                sortable: true,
                dataIndex: 'Name'
            }
        ],
            height: 350,
            width: 600,
            title: 'Pendência com setores',
            renderTo: 'grid-sectors',
            viewConfig: {
                stripeRows: true,
                enableTextSelection: true
            }
        });

    });
</script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Status</legend>

        <div class="editor-label">
            Nome
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            Conclusivo
        </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.Conclusive)
            @Html.ValidationMessageFor(model => model.Conclusive)
        </div>       

        <div class="editor-label">
            Pendência
        </div>

        <div class="editor-field">
            @Html.DropDownListFor(model => model.Dependency, new SelectList(Enum.GetNames(typeof(Helper.Core.Entity.Dependency))) )    
        </div>

        <div id="grid-sectors"></div>

        <p>
            <input type="submit" value="Criar" />
        </p>
    </fieldset>
}


<div>
    @Html.ActionLink("Voltar", "Index")
</div>
